@extends('admin.base')
@section('title', '资产日志')
@section('content')
 <div class="layui-card">
     <fieldset class="layui-elem-field">
         <div class="layui-field-box">
             <a class="layui-btn-sm" href="{{url('admin/home')}}">首页</a>&raquo;
             <span class="layui-btn-sm">资产日志</span>
         </div>
     </fieldset>
    <div class="layui-card-header" style="height:100px">
      <div>
        <span class="pull-left">
          <div class="layui-form">
            <div class="layui-form-item">
              <div class="layui-inline">     
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="sub_keywords" name="keywords" value="{{ isset($request->keywords) ? $request->keywords : '' }}"  placeholder="请输入账户昵称">
                </div>
                 <label class="layui-form-label" style="width:120px">资产类型</label>
                <div class="layui-input-inline">
                    <select name="sub_type" lay-verify="required">
                        <option value="0">请选择</option>
                        <option value="1" @if($request->sub_type == 1) selected @endif>现金</option>
                        <option value="2" @if($request->sub_type == 2) selected @endif>货款</option>
                    </select>
                </div>
                <label class="layui-form-label" style="width:120px">消费类型</label>
                <div class="layui-input-inline">
                    <select name="sub_status" lay-verify="required">
                        <option value="0">请选择</option>
                        <option value="1" @if($request->sub_status== 1) selected @endif>充值</option>
                        <option value="2" @if($request->sub_status == 2) selected @endif>提现</option>
                        <option value="3" @if($request->sub_status == 3) selected @endif>转货款</option>
                        <option value="4" @if($request->sub_status == 4) selected @endif>成为VIP</option>
                        <option value="5" @if($request->sub_status == 5) selected @endif>销售奖</option>
                        <option value="6" @if($request->sub_status == 6) selected @endif>领导奖</option>
                        <option value="7" @if($request->sub_status == 7) selected @endif>教育奖</option>
                        <option value="8" @if($request->sub_status == 8) selected @endif>云仓库收益</option>
                        <option value="9" @if($request->sub_status == 9) selected @endif>后台设置</option>
                        <option value="10" @if($request->sub_status == 10) selected @endif>入库</option>
                        <option value="11" @if($request->sub_status == 11) selected @endif>下单</option>
                        <option value="12" @if($request->sub_status == 12) selected @endif>创客奖</option>
                        <option value="13" @if($request->sub_status == 13) selected @endif>VIP现金返还</option>
                    </select>
                </div>
                <label class="layui-form-label" >时间</label>
                <div class="layui-input-inline">
                    <input  type="text" class="layui-input" class="jeinput" id="test11" placeholder="创建时间(年月日~年月日)" name="month" value="{{ isset($request->month) ? $request->month : '' }}" readonly>
                </div>
                <div class="layui-input-inline">
                  <button class="layui-btn" lay-submit lay-filter="selectsub" style="margin-bottom:10px">搜索</button>
                  <!-- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="exportsub" ></i>导出</button>  -->
                </div>
              </div>
            </div>
          </div>
        </span>
      </div>
    </div>

    <div class="layui-card-body">
        <style>
            table tr td.tc,table tr th.tc {
                text-align: center;
                cursor:default;
            }
        </style>
        <table class="layui-table" lay-even lay-size="">
            <colgroup>
                <col width="">
                <col width="">
                <col width="">
                <col width="">
                <col width="">
                <col width="">
            </colgroup>
            <thead>
                <tr>
                    <th class="tc">昵称</th>
                    <th class="tc">资产类型</th>
                    <th class="tc">消费类型</th>
                    <th class="tc">数量</th>
                    <th class="tc">变更前数量</th>
                    <th class="tc">变更后数量</th>
                    <th class="tc">说明</th>
                    <th class="tc">创建时间</th>
                </tr>
                <tbody>
                    @if($wallet_log->isEmpty())
                        <tr>
                            <td colspan="8" class="tc">暂无数据</td>
                        </tr>
                    @else
                        @foreach ($wallet_log as $v)
                            <tr>
                                <td class="tc">{{ $v->username }}</td>
                                <td class="tc">{{ $v['typename'] }}</td>
                                <td class="tc">{{ $v['statusname'] }}</td>
                                <td class="tc">{{ $v['num'] }}</td>
                                <td class="tc">{{ $v['befor'] }}</td>
                                <td class="tc">{{ $v['after'] }}</td>
                                <td class="tc">{{ $v['msg'] }}</td>
                                <td class="tc">{{$v['created_at']}}</td>
                            </tr>
                        @endforeach
                    @endif
                </tbody>
            </thead>
        </table>
        <!-- 分页 -->
        <div class="sabrosus" >{{ $wallet_log->appends(['keywords'=>$request->keywords,'sub_type'=>$request->sub_type,'sub_status'=>$request->sub_status,'month'=>$request->month])->links() }}</div>
        <!-- {{$wallet_log->total()}} -->
    </div>

 </div>
@endsection
@section('js')
    <script>
        layui.use('form', function(){
            var form = layui.form;

            //搜索
            form.on('submit(selectsub)', function(data){
                let keywords = $('#sub_keywords').val();//关键字
                let month = $("#test11").val();//时间
                var sub_type = $("select[name=sub_type]").val();//资产类型
                var sub_status = $("select[name=sub_status]").val();//消费类型
                location.href = "{{url('admin/user/account_log')}}"+"?keywords="+keywords+"&month="+month+'&sub_type='+sub_type+'&sub_status='+sub_status;
                return false;
            });

            //监听指定开关
            form.on('switch(switchTest)', function(data){
                var id = data.value;

                if(data.elem.checked){
                    var state = 1;//启用
                }else{
                    var state = 2;//禁用               
                }
                ajax('/admin/user/up_state',{id:id,state:state});
            });
        });
    </script>
@endsection